$(function() {
	findCurrent(menuCurrentAlias);
	
	$(".hnavVNN li").each(function(D) {
		var alias = $(this).attr('alias');
		$(this).mouseover(function() {
			findCurrent(alias)
		}).mouseout(function() {}
	)});
	
	$('.hnavBox').mouseleave(function() {
		findCurrent(menuCurrentAlias)
	});
});
function paddingLeftCal(left) {
	var subSize = 0;
	$('a',$('.hnavSUB:visible')).each(function() {
		subSize += $(this).width()+10;
	});
	if((Math.abs(subSize)+left+240)<980) {
		$('.hnavSUB:visible').css({paddingLeft:left});
	}
};

function findCurrent(a) {
	var myregexp = new RegExp(a);
	var flagTest = true;
	$(".hnavVNN li").attr("class","");
	$(".hnavSUB").css('display','none');
	$(".hnavSUB").each(function() {
		if($(this).attr('alias')!=a) { 
			if($('a',$(this)).length>0) {
				if(myregexp.test($(this).html())) {
					flagTest = false;
					$(this).css('display','block');
					$('.hnavVNN li[alias='+$(this).attr("alias")+']').attr("class","current");
					paddingLeftCal($('.hnavVNN li[alias='+$(this).attr("alias")+']').position().left);
				}
			}
		} else {
			flagTest = false;
			$(".hnavSUB").css('display','none');$(".hnavVNN li").attr("class","");
			$('.hnavSUB[alias='+a+']').css('display','block');
			$('.hnavVNN li[alias='+a+']').attr("class","current");
			paddingLeftCal($('.hnavVNN li[alias='+a+']').position().left);
		}
	});
	
	if(flagTest) {
		$(".hnavSUB").css('display','none');
		$(".hnavVNN li").attr("class","");
		$('.hnavSUB:first').css('display','block');
		$('.hnavVNN li:first').attr("class","current");
		paddingLeftCal($('.hnavVNN li:first').position().left)
	}
};
